<template>
    <el-drawer
        v-model="isShow"
        size="50%"
        :destroy-on-close="true"
        @close="closeHandle"
        :close-on-press-escape="false"
        :close-on-click-modal="false"
        :show-close="false"
    >
        <template #header="{ titleId, titleClass }">
            <h4 :id="titleId" :class="titleClass">选择案件</h4>
        </template>
        <el-form ref="queryParamsRef" label-width="100px" :inline="true" :model="queryParams">
            <el-row :gutter="20" style="width: 100%">
                <el-col :span="12">
                    <el-form-item label="部门受案号" style="width: 100%">
                        <el-input v-model="queryParams.casecode" clearable @clear="getTableDataLists"/>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="案件名称" style="width: 100%">
                        <el-input v-model="queryParams.name" 
                        clearable 
                        @clear="getTableDataLists" 
                        @keyup.enter.prevent="getTableDataLists"
                        />
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="申请时间" style="width: 100%">
                        <el-date-picker
                            v-model="dateRange"
                            value-format="YYYY-MM-DD"
                            type="daterange"
                            range-separator="-"
                            start-placeholder="开始日期"
                            end-placeholder="结束日期"
                        ></el-date-picker>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label=" ">
                        <el-button type="primary" @click="getTableDataLists">
                            <el-icon class="me-1">
                                <Search/>
                            </el-icon>
                            查询
                        </el-button>
                    </el-form-item>
                    <el-form-item>
                        <el-button @click="handleRest">
                            <el-icon class="me-1">
                                <Refresh/>
                            </el-icon>
                            重置
                        </el-button>
                    </el-form-item>
                </el-col>
            </el-row>
        </el-form>
        <el-divider class="mt-0 mb-3"/>
        <el-table
            ref="TableDataRef"
            v-loading="loading"
            :data="TablesData"
            show-overflow-tooltip
            highlight-current-row
            @current-change="handleCurrentChange"
        >
            <el-table-column label="部门受案号" prop="name"/>
            <el-table-column label="案件名称" prop="casecode"/>
            
            <el-table-column label="承办人" prop="userName"/>
            <el-table-column label="受案日期" prop="casetype"/>
            <el-table-column label="受案部门" prop="casetype"/>
        </el-table>
        <pagination
            v-show="total > 0"
            :total="total"
            v-model:page="queryParams.pageNum"
            v-model:limit="queryParams.pageSize"
            @pagination="getTableDataLists"
        />
        <template #footer>
            <el-button type="primary" @click="queren">确认</el-button>
            <el-button  @click="isShow = false">关11闭</el-button>
        </template>
    </el-drawer>
</template>
<script setup>
const {proxy} = getCurrentInstance();
// import {getCaseInfoList,getCaseInfoInfo,  deleteCaseInfo} from "@/api/CaseInfo/CaseInfo";
import PageEnum from "@/enum/PageEnum.js";

const {nj_anjian_type,nj_anjian_status} = proxy.useDict('nj_anjian_type', 'nj_anjian_status')

const isShow = ref(false)
const loading = ref(false)

const dateRange = ref([])
const rowvalue = ref()
const queryParams = ref({
    name: '',
    casecode: '',
    // 页码
    pageNum: 1,
    // 分页数量
    pageSize: PageEnum.SIZE
})

const total = ref(0)
const TablesData = ref([{
    name:'111',
    casecode:'第一条数据'
},{
    name:'222',
    casecode:'第二条数据'
}])
// 通知事件
const emit = defineEmits(['getCaseDatas'])

const changeShowStatus = () => {
    isShow.value = !isShow.value
}
onMounted(() => {
    // getTableDataLists()
})
const showCaseList = () => {
    changeShowStatus()
}
defineExpose({showCaseList})

// 获取案件列表
const getTableDataLists = async () => {
    // loading.value = true
    // await getCaseInfoList(proxy.addDateRange(queryParams.value, dateRange.value)).then(res => {
    //     loading.value = false;
    //     TablesData.value = res.rows
    //     total.value = res.total;
    // });
}
const TableDataRef = ref()

const handleCurrentChange = (val) => {
    rowvalue.value = val
}
const queren = () => {
    emit('getCaseDatas', rowvalue.value)
    changeShowStatus()
}
// 重置搜索调解
const handleRest = () => {
    queryParams.value = {
        name: '',
        casecode: '',
    }
    getTableDataLists()
}
// 关闭后的回调事件
const closeHandle = () => {
    queryParams.value = {
        
    }
}
</script>

<style lang="scss" scoped>

</style>